package com.heima.comment.controller;

import com.heima.comment.dto.*;
import com.heima.comment.service.ICommentService;
import com.heima.common.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {

    @Autowired
    private ICommentService commentService;
    @PostMapping("/list")
    public ResponseResult CommentList(@RequestBody CommentDto dto){
        return commentService.list(dto);
    }

    @PostMapping("/manage/comment_repay")
    public ResponseResult repay(@RequestBody RepayDto dto){
        return commentService.repay(dto);
    }

    @DeleteMapping("/manage/del_comment_repay/{id}")
    public ResponseResult deleteRepay(@PathVariable("id") String id){
        return commentService.deleteRepay(id);
    }

    @DeleteMapping("/manage/del_comment/{id}")
    public ResponseResult deleteComment(@PathVariable("id") String id){
        return commentService.delete(id);
    }

    @PostMapping("manage/like")
    public ResponseResult like(@RequestBody LikeDto dto){
        return commentService.like(dto);
    }

    // 发布评论
    @PostMapping("/save")
    public ResponseResult save(@RequestBody CommentSaveDto dto){

        return commentService.save(dto);
    }

    // 查询[评论列表
    @PostMapping("/load")
    public ResponseResult load(@RequestBody CommentDto dto){


        return commentService.load(dto);
    }

    // 评论点赞
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){

        return commentService.likes(dto);
    }
}
